//@charset "utf-8";
var gulp = require('gulp');  
var cmdPack = require('gulp-cmd-pack');  
var uglify = require('gulp-uglify'); 
var concat = require('gulp-concat'),
   minifyCss = require('gulp-minify-css');
   

gulp.task('cmd_pack', function () {  
	gulp.src('./js/static/app.js') //main文件   
		.pipe(cmdPack({  
			mainId: './dist/app', //初始化模块的id   
			base: "./js/sea-modules/",
			alias: {
				'_': 'gallery/underscore/1.4.4/underscore.js',
				'backbone': 'gallery/backbone/1.0.0/backbone-debug.js'
			}
		}))
		.pipe(gulp.dest('dist'));//输出到目录   
});  

gulp.task('js_concat',['cmd_pack'],function() {
	return gulp.src(['./js/sea-modules/seajs/seajs/2.1.0/sea.js','./js/static/bootstrap.js','./dist/app.js'])
	   .pipe(concat('main.js'))
	   .pipe(uglify({
	   	mangle: {
	   		except: ['require']
	   	}
	   }))
	   .pipe(gulp.dest('./dist'));
});

gulp.task('minify-css', function() {
	console.log('hello world');
	gulp.src('css/*.css')
		.pipe(minifyCss())
		.pipe(gulp.dest('dist-css/css'));
});

gulp.task('default',['js_concat']);